#ifndef CAMERA_H
#define CAMERA_H

//using namespace DirectX;

#include "Config.h"

class Camera {

	public:

		Camera(Config*);
		void ResetCamera();

		// Get/Set world camera position.
		XMVECTOR GetPositionXM() const;
		void SetPosition(XMVECTOR);
	
		// Get camera basis vectors.
		XMVECTOR GetRight() const;
		XMVECTOR GetUp() const;
		XMVECTOR GetLook() const;

		// Get frustum properties.
		float GetNearZ() const;
		float GetFarZ() const;
		float GetAspect() const;
		float GetFovY() const;
		float GetFovX() const;

		// Get near and far plane dimensions in view space coordinates.
		float GetNearWindowWidth() const;
		float GetNearWindowHeight() const;
		float GetFarWindowWidth() const;
		float GetFarWindowHeight() const;
	
		// Set frustum.
		void SetLens(float, float, float, float);

		// Define camera space via LookAt parameters.
		void LookAt(XMVECTOR pos, XMVECTOR target, XMVECTOR worldUp);

		// Get View/Proj matrices.
		XMMATRIX View() const;
		XMMATRIX Proj() const;
		XMMATRIX ViewProj() const;

		// Strafe/Walk the camera a distance d.
		void Strafe(float d);
		void Hover(float d);
		void Walk(float d);

		// Rotate the camera.
		void Pitch(float angle); //= up-down rotation
		void RotateY(float angle); //= left-right rotation

		// After modifying camera position/orientation, call to rebuild the view matrix.
		void UpdateViewMatrix();

	private:

		// Camera coordinate system with coordinates relative to world space.
		XMVECTOR mPosition;
		XMVECTOR mRight;
		XMVECTOR mUp;
		XMVECTOR mLook;

		// Cache frustum properties.
		float mNearZ;
		float mFarZ;
		float mAspect;
		float mFovY;
		float mNearWindowHeight;
		float mFarWindowHeight;

		// Cache View/Proj matrices.
		XMMATRIX mView;
		XMMATRIX mProj;

		Config* config;
};

#endif